import {request} from "@/utils/request";
import {getToken} from "@/utils/storage";

export function list() {
    return request({
        url: '/api/grade/listStatusIsTrue',
        method: 'get',
        headers: {"token": getToken()}
    })
}

export function list_QWQ(status) {
    if (typeof status == "undefined") {
        return request({
            url: '/api/grade/list',
            method: 'get',
            headers: {"token": getToken()}
        })
    } else {
        return request({
            url: '/api/grade/list',
            method: 'get',
            headers: {"token": getToken()},
            params: {"status": status.toString()}
        })
    }

}

export function removeById(id) {
    return request({
        url: `/api/grade/remove/${id}`,
        method: "delete",
        headers: {"token": getToken()}
    })
}

export function removeGradeUserById(gId, uId) {
    return request({
        url: `/api/grade/removeByUid/${gId}/${uId}`,
        method: "DELETE",
        headers: {"token": getToken()}
    })
}

export function getNotGUserListBycid(id) {
    return request({
        url: `/api/user/getUserByCid/${id}`,
        method: "get",
        headers: {"token": getToken()}
    })
}

export function saveUser(gradeId, ids) {
    return request({
        url: `/api/grade/addUserToGradeByUid/${gradeId}/${ids}`,
        method: 'post',
        headers: {"token": getToken()}
    })
}

export function saveGrade(name) {
    return request({
        url: '/api/grade/addGrade/' + name,
        method: 'post',
        headers: {"token": getToken()},
    })
}

export function statusById(id) {
    return request({
        url: `/api/grade/status/${id}`,
        method: "put",
        headers: {"token": getToken()}
    })
}
